<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>模块配置选项</title>

    {% include 'system/common/header.html' %}
</head>
<body class="pear-container">
<form class="layui-form" action="" onsubmit="return false">
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-tab">
<ul class="layui-tab-title">
    {% for key in jsonconf.keys() %}
         {% if key == '__sys__' %}
         <li class="layui-this">默认配置</li>
        {% else %}
        <li>{{ key }}</li>
        {% endif %}
    {% endfor %}
</ul>
<div class="layui-tab-content">
    {% for key in jsonconf.keys() %}
        {% if key == '__sys__' %}
            <div class="layui-tab-item layui-show">
            {% for k in jsonconf[key].keys() %}
                <div class="layui-form-item">
                    <label class="layui-form-label">{{ jsonconf['__sys__'][k]['name'] }}</label>
                    <div class="layui-input-block">
                        <textarea name="{{ k }}"  class="layui-input helpbox"  lay-verify="required" placeholder="{{ jsonconf['__sys__'][k]['des'] }}">{{ jsonconf['__sys__'][k]['val'] }}</textarea>
                    </div>

                  </div>


            {% endfor %}
            </div>
        {% else %}
            <div class="layui-tab-item">
            {% for k in jsonconf[key].keys() %}
                <div class="layui-form-item">
                    <label class="layui-form-label">{{ jsonconf[key][k]['name'] }}</label>
                    <div class="layui-input-block">
                        <textarea name="{{ k }}"  class="layui-input helpbox"  lay-verify="required" placeholder="{{ jsonconf[key][k]['des'] }}">{{ jsonconf[key][k]['val'] }}</textarea>
                    </div>

                  </div>

            {% endfor %}
            </div>
        {% endif %}
    {% endfor %}
  </div>
</div>
<div class="layui-form-item">
    <div class="layui-input-block">
       <input type="hidden" name="appdir" value="{{ appdir }}" />
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>

</div></div>
</form>
{% include 'system/common/footer.html' %}
<script>
  layui.use(['form','jquery','layer'], function(){
    var form = layui.form;
    var $ = layui.jquery;
    let layer = layui.layer;
    form.on('submit(formDemo)', function(data){
      //layer.msg(JSON.stringify(data.field));
      $.ajax({
          url: '{{ url_for('plugins.config') }}',
          type: 'post',
          data: data.field,
          success: function(res){
              if(res.success == true){
                  layer.msg(res.msg)
              }else{
                  layer.msg('保存失败！')
              }
          }
      })
      return false;
    });

    $('.helpbox').hover(function(){
      layer.tips($(this).attr('placeholder'), $(this), {
        tips: [3, '#3595CC']
        ,time: 3000
      })
    })
  });
</script>
</body>
</html>